﻿using System.Windows.Controls;
using Officer2013.Infrastructure.ViewServices;
using nRoute.ViewServices;
using nRoute.Mapping;
using nRoute.ApplicationServices;
using nRoute.Components.Composition;
using nRoute.Components;
using System;

namespace Officer2013
{
    //[MapViewService(typeof(IMessageViewService), "ShellShowMessageViewService", LifetimeManagerType =  typeof(DiscoveredInstanceLifetimeManager))]
	public partial class Shell 
        : UserControl, IMessageViewService
	{
        private const string MESSAGE_PARMKEY = "Message";
        private const string ACKN_MSG_FORMAT = "Acknowledging request to '{0}'";

        public Shell()
		{
			InitializeComponent();

            //this.SetRelayValue<Type>("ViewServiceTypeRelay", typeof(IMessageViewService));

            //// register this as service
            //(nRouteApplicationService.Current.ResourceCatalog as IResourceCatalogEx).CatalogResource<IMessageViewService>(
            //    "ShellShowMessageViewService", new FactoryResourceLocator<IMessageViewService>((t) => this), true);
		}

#region IShowMessageViewService Members

        void IMessageViewService.ShowMessage(string message)
        {
            if (string.IsNullOrEmpty(message)) return;

            BallonText.Text = string.Format(ACKN_MSG_FORMAT, message);
            BallonStoryboard.Begin();
        }

#endregion

        private void ViewServiceTypeRelay_Initialize_1(object sender, ValueEventArgs<object> e)
        {
            e.Value = typeof(IMessageViewService);
        }

    }
}